package jp.co.showbiz.admin.report.dao;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;

import jp.co.showbiz.admin.report.imp.ContentInfoDto;
import jp.co.showbiz.admin.report.imp.DigestDto;
import jp.co.showbiz.admin.report.imp.ReportDetailContentDto;
import jp.co.showbiz.admin.report.imp.ReportDetailDto;
import jp.co.showbiz.admin.report.imp.ReportDto;
import jp.co.showbiz.admin.talent.imp.TalentDto;
import jp.co.showbiz.common.base.BaseDAO;
import jp.co.showbiz.common.base.BaseException;
import jp.co.showbiz.common.entity.CommonMstBean;
import jp.co.showbiz.common.entity.ContentMstBean;
import jp.co.showbiz.common.entity.KijiBean;
import jp.co.showbiz.common.entity.KijiDigestBean;
import jp.co.showbiz.common.entity.KijiDigestContentBean;
import jp.co.showbiz.common.entity.TalentContentBean;
import jp.co.showbiz.common.entity.TalentSenyouBean;

public class ReportDao extends BaseDAO {

	public ReportDao() throws BaseException, IOException {
		super();
	}
	public CommonMstBean getCommonCode(CommonMstBean bean) throws SQLException {
		return (CommonMstBean) sqlMap.queryForObject("report.getCommonCode", bean);
	}
	public List<CommonMstBean> getMovieKubun() throws SQLException {
		return sqlMap.queryForList("report.selectMovieKubun");
	}
	public int getTotalCount(String disc) throws SQLException {
		return (Integer) sqlMap.queryForObject("report.selectReportTotal", disc);
	}
	public List<ReportDto> getReportList(String disc, int skip, int maxSize) throws SQLException {
		return sqlMap.queryForList("report.selectReportList", disc, skip, maxSize);
	}
	public Object getLastestPk() throws SQLException {
		return sqlMap.queryForObject("report.selectReportPk");
	}
	public String getReportCode() throws SQLException {
		return (String) sqlMap.queryForObject("report.selectReportCode");
	}
	public List<TalentDto> getTalentList() throws SQLException {
		return sqlMap.queryForList("report.selectTalent");
	}
	public void registeBagicReportInfo(KijiBean bean) throws SQLException {
		sqlMap.insert("report.insertBagic", bean);
	}
	public void updateKijiContents(HashMap<String, String> contents) throws SQLException {
		sqlMap.update("report.updateContent", contents);
	}
	public Object getLastestContentPk() throws SQLException {
		return sqlMap.queryForObject("report.selectContentPk");
	}
	public void registeContents(ContentMstBean bean) throws SQLException {
		sqlMap.insert("report.registContent", bean);
	}
	public void registeContentTalent(TalentContentBean bean) throws SQLException {
		sqlMap.insert("report.registContentTalent", bean);
	}
	public void registeTalentSenyou(TalentSenyouBean bean) throws SQLException {
		sqlMap.insert("report.registTalentSenyou", bean);
	}
	public ReportDetailDto getReportDetail(ReportDto rBean) throws SQLException {
		return (ReportDetailDto) sqlMap.queryForObject("report.selectReportDetail", rBean);
	}
	public List<ReportDetailDto> getReportDetail(ReportDto rBean ,String str) throws SQLException {
		return (List<ReportDetailDto>) sqlMap.queryForList("report.selectReportDetail", rBean);
	}

	public void updateReportBasicInfo(ReportDto rBean) throws SQLException {
		sqlMap.update("report.updateReportBasicInfo", rBean);
	}
	public List<ReportDetailContentDto> getKijiContent(ReportDto bean) throws SQLException {
		return sqlMap.queryForList("report.selectKijiContent", Integer.parseInt(bean.getId()));
	}
	public void registeDigest(KijiDigestBean dBean) throws SQLException {
		sqlMap.insert("report.registeDigest", dBean);
	}
	public List<DigestDto> selectDigestList(String kijiId) throws SQLException {
		return sqlMap.queryForList("report.selectDigestList", kijiId);
	}
	public DigestDto selectDigestDetail(String id) throws SQLException {
		return (DigestDto) sqlMap.queryForObject("report.selectDigestDetail", id);
	}
	public List<TalentDto> getTalentContent(String id) throws SQLException {
		return sqlMap.queryForList("report.selectTalentContent", id);
	}
	public void updateDigestDetail(DigestDto dto) throws SQLException {
		sqlMap.update("report.updateDegist", dto);
	}
	public Object getLastestDigestPk() throws SQLException {
		return sqlMap.queryForObject("report.selectDigestPk");
	}
	public ReportDto getKijiTalent(String kijiId) throws SQLException {
		return (ReportDto) sqlMap.queryForObject("report.selectKijiTalent", kijiId);
	}
	public void registeKijiDigestContent(KijiDigestContentBean bean) throws SQLException {
		sqlMap.insert("report.registeKijiDigestContent", bean);
	}
	public List<DigestDto> getOldDigestContent(String digestId) throws SQLException {
		return sqlMap.queryForList("report.oldDigestContent", digestId);
	}
	public void deleteOldDigestContent(DigestDto dBean) throws SQLException {
		sqlMap.delete("report.deleteOldDigestContent", dBean);
	}
	public void updateKijiMainImageComment(ReportDto rBean) throws SQLException {
		sqlMap.update("report.modifyMainImgComment", rBean);
	}
	public void updateDigestImageComment(DigestDto dBean) throws SQLException {
		sqlMap.update("report.modifyDigestImgComment", dBean);
	}
	public Integer getDigestMaxSeq(String id) throws SQLException {
		return (Integer) sqlMap.queryForObject("report.selectDigestMaxSeq", id);
	}
	public HashMap<String, Integer> getContentsPoint() throws SQLException {
		return (HashMap<String, Integer>) sqlMap.queryForMap("report.selectContentsPointMap", null, "content_kubun", "point_value");
	}
	public List<CommonMstBean> getgetKijiDiscValue() throws SQLException {
		return sqlMap.queryForList("report.getKijiDiscValue");
	}
	public String getDigestContent(String digestId) throws SQLException {
		return (String) sqlMap.queryForObject("report.selectDigestContent", digestId);
	}
	public void updateKijiContentStartDate(ReportDto dto) throws SQLException {
		sqlMap.update("updateKijiContentStartDate", dto);
	}
	/*public void updateKijiContentTitle(ReportDto dto) throws SQLException {
		sqlMap.update("updateKijiContentTitle", dto);
	}*/
	public void updateKijiContent(ContentMstBean bean) throws SQLException {
		sqlMap.update("updateKijiContent", bean);
	}
	public List<Hashtable> getDigestImageInfo(DigestDto dto) throws SQLException {
		return sqlMap.queryForList("report.selectDigestImageContent", dto);
	}
	public ContentInfoDto getDigestImageInfo(int content_id) throws SQLException {
		return (ContentInfoDto) sqlMap.queryForObject("report.selectDigestImageInfo", content_id);
	}
	public void updateDigestImageInfo(ContentInfoDto dto) throws SQLException {
		sqlMap.update("report.updateDigestImageInfo", dto);
	}
	public void deleteContent(ContentInfoDto dto) throws SQLException {
		int content_id = dto.getContent_id();
		sqlMap.delete("deleteContentDlInfo", content_id);
		sqlMap.delete("deleteDigestContent", content_id);
		sqlMap.delete("deleteTalentContent", content_id);
		sqlMap.delete("deleteTalentOnly", content_id);
		sqlMap.delete("deleteContent", content_id);
	}
}
